<%@ page language="java" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<%
			response.addHeader("Pragma", "no-cache");
			response.setHeader("Cache-Control", "no-cache");
			response.setDateHeader("Expires", 0);
		%>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>周报填写</title>
		<link href="css/sys.css" rel="stylesheet" type="text/css">
		<link rel="stylesheet" type="text/css"
			href="jeasyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="jeasyui/themes/icon.css">
		<script src="js/jquery.js"></script>
		<script type="text/javascript" src="jeasyui/jquery.easyui.min.js"></script>
		<script type="text/javascript"
			src="jeasyui/locale/easyui-lang-zh_CN.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
		<style type="text/css">
			.showweeklog{
				width: 100%;
				height: 150px;
			}
		</style>
		<script type="text/javascript">
	$(function() {
		WdatePicker({
			isShowWeek : true,
			eCont : "div1",
			onpicked : function(dp) {
				$("#showmyweeklog").empty();
				var url="weeklog.do?method=getNowDateWeekLogList&nowweek="
					+ dp.cal.getP('W','W')+"&nowtime="+new Date();
				showweeklog(url);
			}
		});
	});
	function searchweeklog(){
		if($("#seachstartweek").val()==""){
			$.messager.alert("提示","开始周不能为空~~","info");
			return;
		}else if($("#seachendweek").val()==""){
			$.messager.alert("提示","结束周不能为空~~","info");
			return;
		}else if($("#seachstartweek").val()>$("#seachendweek").val()){
			$.messager.alert("提示","开始周不能晚于结束周~~","info");
			return;
		}
		var url = "weeklog.do?method=searchWeekLogList&startweek="
			+ $("#seachstartweek").val()+"&endweek="+$("#seachendweek").val()+"&nowtime="+new Date();
		$("#showmyweeklog").empty();
		showweeklog(url);
	}
	//添加模块
	function addmyweeklog() {
		$("#commitdate").attr("value", nowDate());
		$("#myweeklog").show();
		$("#myweeklog").dialog({
			title : "添加周报",
			modal : true,
			width : 780,
			height : 520,
			collapsible : true,
			minimizable : false,
			maximizable : false,
			buttons : [ {
				text : "提交",
				iconCls : "icon-ok",
				handler :function(){tijiao();}
			},{
				text : "保存",
				iconCls : "icon-ok",
				handler :function(){ baocun();}
			},{
				text : "取消",
				iconCls : "icon-undo",
				handler : function(){quxiao();}
			}]
		});
	}

	function baocun() {
		$("#iscommit").attr("value", "0");
		$("#myworkform").form("submit", {
			url : "weeklog.do?method=addweeklog&nowtime="+new Date(),
			onSubmit : function() {
				var flag = true;
				if ($("#weekofyear").val() == "") {
					$.messager.alert("警告信息", "选择周次~~", "warning");
					flag = false;
				} else if ($("#commitdate").val() == "") {
					$.messager.alert("警告信息", "选择填报日期~~", "warning");
					flag = false;
				} else if($("#weekcontent").val() == ""){
					$.messager.alert("警告信息", "输入工作周报内容~~", "warning");
					flag = false;
				} 
				return flag;
			},
			success : function(data) {
				$("#myweeklog").dialog("close");
				showmsg(data);
			}
		});
		$("#showmyweeklog").empty();
		var url="weeklog.do?method=getNowDateWeekLogList&nowweek="
			+ $("#weekofyear").val()+"&nowtime="+new Date();
		showweeklog(url);
	}

	function tijiao() {
		$("#iscommit").attr("value", "1");
		$("#myweekform").form("submit", {
			url : "weeklog.do?method=addWeekLog&nowtime="+new Date(),
			onSubmit : function() {
				var flag = true;
				if ($("#weekofyear").val() == "") {
					$.messager.alert("警告信息", "选择周次~~", "warning");
					flag = false;
				} else if ($("#commitdate").val() == "") {
					$.messager.alert("警告信息", "选择填报日期~~", "warning");
					flag = false;
				} else if($("#weekcontent").val() == ""){
					$.messager.alert("警告信息", "输入工作周报内容~~", "warning");
					flag = false;
				} 
				return flag;
			},
			success : function(data) {
				$("#myweeklog").dialog("close");
				showmsg(data);
			}
		});
		$("#showmyweeklog").empty();
		var url="weeklog.do?method=getNowDateWeekLogList&nowweek="
			+ $("#weekofyear").val()+"&nowtime="+new Date();
		showweeklog(url);
	}
	function gengxin(){
		$("#myweekform").form("submit", {
			url : "weeklog.do?method=updateWeekLog&nowtime="+new Date(),
			onSubmit : function() {
				var flag = true;
				if ($("#weekofyear").val() == "") {
					$.messager.alert("警告信息", "选择周次~~", "warning");
					flag = false;
				} else if ($("#commitdate").val() == "") {
					$.messager.alert("警告信息", "选择填报日期~~", "warning");
					flag = false;
				} else if($("#weekcontent").val() == ""){
					$.messager.alert("警告信息", "输入工作周报内容~~", "warning");
					flag = false;
				} 
				return flag;
			},
			success : function(data) {
				$("#myweeklog").dialog("close");
				showmsg(data);
			}
		});
		$("#showmyweeklog").empty();
		var url="weeklog.do?method=getNowDateWeekLogList&nowweek="
			+ $("#weekofyear").val()+"&nowtime="+new Date();
		showweeklog(url);
	}
	function updateweeklog(weeklogid){
		$.ajax({
			type : "POST",
			dataType : "json",
			url : "weeklog.do?method=getWeekLogByid&nowtime=" + new Date(),
			data : {
				"id" : weeklogid
			},
			success : function(data) {
				$("#id").attr("value", data.id);
				$("#iscommit").attr("value", data.iscommit);
				$("#userid").attr("value", data.userid);
				$("#weekofyear").attr("value", data.weekofyear);
				$("#completion").attr("value", data.completion);
				$("#commitdate").attr("value", data.commitdate);
				$("#weekcontent").attr("value", data.weekcontent);
				$("#questioncontent").attr("value", data.questioncontent);
				$("#nextweekcontent").attr("value", data.nextweekcontent);
			}
		});
		$("#myweeklog").show();
		$("#myweeklog").dialog({
			title : "更新周报",
			modal : true,
			width : 780,
			height : 520,
			collapsible : true,
			minimizable : false,
			maximizable : false,
			buttons : [{
				text : "更新",
				iconCls : "icon-ok",
				handler :function(){ gengxin();}
			},{
				text : "取消",
				iconCls : "icon-undo",
				handler : function(){quxiao();}
			}]
		});
	}
	function commitweeklog(weeklogid){
		$.ajax({
			type : "POST",
			dataType : "text",
			url : "weeklog.do?method=commitWeekLog&iscommit=1&nowtime=" + new Date(),
			data:{
				"id":weeklogid
			},
			success : function(data) {
				showmsg(data);
			}
		});
		$("#showmyweeklog").empty();
		searchweeklog();
	}
	function quxiao() {
		$("#myweeklog").dialog("close");
	}

	function showweeklog(url) {
		$
				.ajax({
					type : "get",
					dataType : "json",
					url : url,
					success : function(data) {
						$
								.each(
										data,
										function(index, weeklog) {
											var commitflag="已经提交~~";
											if(weeklog.iscommit==0){
												commitflag="<a href='javascript:void(0)' onclick=\"updateweeklog('"+weeklog.id+"')\">修改</a>|<a href='javascript:void(0)' onclick=\"commitweeklog('"+weeklog.id+"')\">提交</a>";
											}
											$("#showmyweeklog")
													.append(
															"<div id='"+weeklog.id+"' class='icon-worklog'>第"
																	+ weeklog.weekofyear+"周["+commitflag
																	+"]</div><table width='100%' bgcolor='#F7FBFF'>"
																	+ "<tr><td align='right' width='15%'>提交时间：</td><td>"
																	+ weeklog.commitdate
																	+ "</td>"
																	+ "<td align='right' width='15%'>工作完成度：</td><td>"
																	+ weeklog.completion
																	+ "</td></tr>"
																	+ "<tr><td align='right' width='15%'>周工作总结：</td><td colspan='3'><textarea class='showweeklog' readonly='readonly'>"
																	+ weeklog.weekcontent
																	+ "</textarea></td></tr>"
																	+ "<tr><td align='right' width='15%'>问题记录：</td><td colspan='3'><textarea class='showweeklog' readonly='readonly'>"
																	+ weeklog.questioncontent
																	+ "</textarea></td></tr>"
																	+ "<tr><td align='right' width='15%'>下周工作计划：</td><td colspan='3'><textarea class='showweeklog' readonly='readonly'>"
																	+ weeklog.nextweekcontent
																	+ "</textarea></td></tr></table>");
										});
					}
				});
	}
</script>
	</head>
	<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
		<div region="west" style="width: 200px; overflow: hidden" id="west">
			<div
				style="background-color: #E0EC00; margin-top: 1px; text-align: center;">
				<a href="javascript:void(0)" onclick="addmyweeklog()">添加周报</a>
			</div>
			<div id="div1" align="center"></div>
			<div
				style="background-color: #E0EC00; margin-top: 20px; text-align: center;">
				周报查询
			</div>
			<form action="" >
				<div>
					<label>
						开始周:
					</label>
					<input type="hidden"" name="s1" id="s1"/>
					<input type="text"" name="seachstartweek" id="seachstartweek" readonly="readonly" value="1"/>
					<img onclick="WdatePicker({el:'s1',isShowWeek:true,onpicked:function() {$dp.$('seachstartweek').value=$dp.cal.getP('W','W');}})" src="My97DatePicker/skin/datePicker.gif" width="16" height="22">
				</div>
				<div>
					<label>
						结束周:
					</label>
					<input type="hidden"" name="s2" id="s2"/>
					<input type="text" name="seachendweek" id="seachendweek" readonly="readonly" value="1"/>
					<img onclick="WdatePicker({el:'s2',isShowWeek:true,onpicked:function() {$dp.$('seachendweek').value=$dp.cal.getP('W','W');}})" src="My97DatePicker/skin/datePicker.gif" width="16" height="22">
				</div>
				<div align="center">
					<a href="javascript:void(0)" class="easyui-linkbutton" plain="true"
						icon="icon-search" onclick="searchweeklog()">查询</a>
				</div>
			</form>
		</div>
		<div id="mainPanle" region="center" >
			<div id="showmyweeklog">
			欢迎填写工作周报！
			</div>
		</div>
		<div id="myweeklog" style="display: none; text-align: center;">
			<form action="" id="myweekform" name="myweekform" method="post">
			<input type="hidden" name="id" id="id">
			<input id="iscommit" name="iscommit" type="hidden">
			<input id="userid" name="userid" type="hidden">
				<table align="center" width="100%" >
					<tr>
						<td align="right">选择周次:</td>
						<td>
						<input type="hidden"" name="s3" id="s3"/>
						第<input type="text" name="weekofyear" id="weekofyear" style="width: 30px" readonly="readonly">周
					<img onclick="WdatePicker({el:'s3',isShowWeek:true,onpicked:function() {$dp.$('weekofyear').value=$dp.cal.getP('W','W');}})" src="My97DatePicker/skin/datePicker.gif" width="16" height="22">
						</td>
						<td align="right">
							工作完成度：
						</td>
						<td>
						<select name="completion" id="completion">
						<option value="100%">100%</option>
						<option value="90%">90%</option>
						<option value="80%">80%</option>
						<option value="70%">70%</option>
						<option value="60%">60%</option>
						<option value="50%">50%</option>
						<option value="40%">40%</option>
						<option value="30%">30%</option>
						<option value="20%">20%</option>
						<option value="10%">10%</option>
						</select>
						</td>
						<td align="right">
							填报日期：
						</td>
						<td>
							<input type="text" " name="commitdate" id="commitdate"
								onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" class="Wdate" />
						</td>
					</tr>
					<tr>
						<td align="right">
							周工作总结：
						</td>
						<td colspan="5">
							<textarea name="weekcontent" id="weekcontent"
								style="width: 100%; height: 150px;" class="easyui-validatebox" required="true"></textarea>
						</td>
					</tr>
					<tr>
						<td align="right">
							问题记录：
						</td>
						<td colspan="5">
							<textarea name="questioncontent" id="questioncontent"
								style="width: 100%; height: 150px;"></textarea>
						</td>
					</tr>
					<tr>
						<td align="right">
							下周工作计划：
						</td>
						<td colspan="5">
						<textarea name="nextweekcontent" id="nextweekcontent"
								style="width: 100%; height: 150px;"></textarea>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</body>
</html>
